package ztc.control;

import ztc.view.Display;

import java.security.DigestInputStream;
import java.util.Map;

/**
 * Created by ztc on 15-11-19.
 */
public class myex {
    static Display display;

    public static Display getDisplay() {
        return display;
    }

    public static void setDisplay(Display display) {
        myex.display = display;
    }
    public static String getNow(Map map){
        String now="";
        if(map.containsKey("_HeWeather data service 3.0_now_cond_txt"))
            now+="天     气："+map.get("_HeWeather data service 3.0_now_cond_txt")+"\r\n";
        if(map.containsKey("_HeWeather data service 3.0_now_wind_dir"))
            now+="风     向："+map.get("_HeWeather data service 3.0_now_wind_dir")+"\r\n";
        if(map.containsKey("_HeWeather data service 3.0_now_wind_sc"))
            now+="风     力："+map.get("_HeWeather data service 3.0_now_wind_sc")+"\r\n";
        if(map.containsKey("_HeWeather data service 3.0_now_wind_spd"))
            now+="风     速："+map.get("_HeWeather data service 3.0_now_wind_spd")+" kmph\r\n";
        if(map.containsKey("_HeWeather data service 3.0_now_fl"))
            now+="体感温度："+map.get("_HeWeather data service 3.0_now_fl")+"\r\n";
        if(map.containsKey("_HeWeather data service 3.0_now_tmp"))
            now+="温     度："+map.get("_HeWeather data service 3.0_now_tmp")+"\r\n";
        if(map.containsKey("_HeWeather data service 3.0_now_hum"))
            now+="相对湿度:"+map.get("_HeWeather data service 3.0_now_hum")+" %\r\n";
        if(map.containsKey("_HeWeather data service 3.0_now_pcpn"))
            now+="降 水   量："+map.get("_HeWeather data service 3.0_now_pcpn")+" mm\r\n";
        if(map.containsKey("_HeWeather data service 3.0_now_pres"))
            now+="气     压："+map.get("_HeWeather data service 3.0_now_pres")+"\r\n";
        if(map.containsKey("_HeWeather data service 3.0_now_vis"))
            now+="能 见   度："+map.get("_HeWeather data service 3.0_now_vis")+" km\r\n";
        return now;
    }
    public  static String getBasic(Map map){
        String basic="";

        if(map.containsKey("_HeWeather data service 3.0_basic_cnty"))
            basic+=map.get("_HeWeather data service 3.0_basic_cnty")
                    +"-"+(String)map.get("_HeWeather data service 3.0_basic_city")
                    +"-"+"更新时间："+map.get("_HeWeather data service 3.0_basic_update_loc");
        return basic;
    }
    public static String getAqi(Map map){
        String aqi="";
        if(map.containsKey("_HeWeather data service 3.0_aqi_city_no2"))
            aqi+="空气质量指数："+map.get("_HeWeather data service 3.0_aqi_city_no2")+"\r\n"
                    +"空气质量类别:"+map.get("_HeWeather data service 3.0_aqi_city_qlty")+"\r\n"
                    +"一氧化碳1小时平均值:"+map.get("_HeWeather data service 3.0_aqi_city_co")+" ug/m³\r\n"
                    +"二氧化氮1小时平均值:"+map.get("_HeWeather data service 3.0_aqi_city_so2")+" ug/m³\r\n"
                    +"臭氧1小时平均值:"+map.get("_HeWeather data service 3.0_aqi_city_o3")+" ug/m³\r\n"
                    +"PM10 1小时平均值:"+map.get("_HeWeather data service 3.0_aqi_city_pm10")+" ug/m³\r\n"
                    +"PM2.5 1小时平均值:"+map.get("_HeWeather data service 3.0_aqi_city_pm25")+" ug/m³\r\n"
                    +"二氧化硫1小时平均值"+map.get("_HeWeather data service 3.0_aqi_city_so2")+" ug/m³\r\n";
        return aqi;
    }
    public static String getSuggestion(Map map){
        String suggestion="";
        if(map.containsKey("_HeWeather data service 3.0_suggestion_uv_txt"))
            suggestion+="舒适度指数:\r\n  "+map.get("_HeWeather data service 3.0_suggestion_comf_txt")+"\r\n"
                    +"洗车指数:\r\n  "+map.get("_HeWeather data service 3.0_suggestion_cw_txt")+"\r\n"
                    +"穿衣指数:\r\n  "+map.get("_HeWeather data service 3.0_suggestion_drsg_txt")+"\r\n"
                    +"感冒指数:\r\n  "+map.get("_HeWeather data service 3.0_suggestion_flu_txt")+"\r\n"
                    +"运动指数:\r\n  "+map.get("_HeWeather data service 3.0_suggestion_sport_txt")+"\r\n"
                    +"旅游指数:\r\n  "+map.get("_HeWeather data service 3.0_suggestion_trav_txt")+"\r\n"
                    +"紫外线指数:\r\n  "+map.get("_HeWeather data service 3.0_suggestion_uv_txt")+"\r\n";
        return suggestion;
    }
    public static String getHourly(Map map){
        String hourly="";
        String sign="";
        while(true) {
            if (map.containsKey("_HeWeather data service 3.0_hourly_forecast"+sign+"_date"))
                hourly += "时间：" + map.get("_HeWeather data service 3.0_hourly_forecast"+sign+"_date") + "\r\n"
                        + "温度:" + map.get("_HeWeather data service 3.0_hourly_forecast"+sign+"_tmp") + "\r\n"
                        + "降水概率:" + map.get("_HeWeather data service 3.0_hourly_forecast"+sign+"_pop") + " %\r\n"
                        + "相对湿度:" + map.get("_HeWeather data service 3.0_hourly_forecast"+sign+"_hum") + " %\r\n"
                        + "气压:" + map.get("_HeWeather data service 3.0_hourly_forecast"+sign+"_pres") + "\r\n"
                        + "风向:" + map.get("_HeWeather data service 3.0_hourly_forecast"+sign+"_wind_dir") + "\r\n"
                        + "风力:" + map.get("_HeWeather data service 3.0_hourly_forecast"+sign+"_wind_sc") + "\r\n"
                        + "风速:" + map.get("_HeWeather data service 3.0_hourly_forecast"+sign+"_wind_spd") + " kmph\r\n"
                        + "\r\n";
            else
                break;
            sign+="*";
        }
        return hourly;
    }
    public static String getDaily(Map map){
        String daily="";
        String sign="";
        while(true) {
            if (map.containsKey("_HeWeather data service 3.0_daily_forecast" + sign + "_date"))
                daily += "预报日期:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_date") + "\r\n"
                        + "日出时间:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_astro_sr") + "\r\n"
                        + "日落时间:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_astro_ss") + "\r\n"
                        + "白天天气:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_cond_txt_d") + "\r\n"
                        + "夜间天气:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_cond_txt_n") + "\r\n"
                        + "最高温度:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_tmp_max") + "\r\n"
                        + "最低温度:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_tmp_min") + "\r\n"
                        + "风向:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_wind_dir") + "\r\n"
                        + "风力:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_wind_sc") + "\r\n"
                        + "风速:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_wind_spd") + " kmph\r\n"
                        + "相对湿度:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_hum") + "\r\n"
                        + "降水量:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_pcpn") + "\r\n"
                        + "气压:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_pres") + "\r\n"
                        + "能见度:" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_vis") + "\r\n"
                        + "降水概率" + map.get("_HeWeather data service 3.0_daily_forecast" + sign + "_pop") + " %\r\n"
                        + "\r\n";
            else
                break;
            sign+="*";
        }
        return daily;
    }
}
